package com.me.libgdx_test;

import java.util.ArrayList;
import java.util.Arrays;

//Shroud Restore: health, mana, cure disease chance
//Shroud visibility enemy: +8% atk each enemy seen, +5 health for each living enemy
//Shroud visibility over enemy/spell: can see monsters equal lower level, can see all spells
//Shroud removal around enemy: +20% dblhit/dodge, first strike
public class ClassPlayerShroudMod {
	int restore_health;
	int restore_mana;
	float cure_disease;
	boolean half_shroud;
	String enemy_visibility;
	ArrayList<String> see_through_shrouds;
	String removal_around_enemy;
	ClassPlayerShroudMod(int restore_health, int restore_mana, float cure_disease, 
			String enemy_visibility, String removal_around_enemy, boolean half_shroud, String...see_through_shrouds){
		this.restore_health = restore_health;
		this.restore_mana = restore_mana;
		this.cure_disease = cure_disease;
		this.enemy_visibility = enemy_visibility;
		this.see_through_shrouds = new ArrayList<String>(Arrays.asList(see_through_shrouds));
		//this.see_through_shrouds = new String[see_through_shrouds.length];
		//System.arraycopy( see_through_shrouds, 0, this.see_through_shrouds, 0, see_through_shrouds.length );
		this.removal_around_enemy = removal_around_enemy;
		this.half_shroud = half_shroud;
	}
	public void cure_disease_chance(ClassCharacterPlayer player){
		for(ClassCharacterModDungeon contracted_mod : player.contracted_mods){
			if(contracted_mod.get_info_mods().get_ailment() && contracted_mod.get_has_mod()){
				if(player.roll((int)(100*cure_disease), 100)){
					contracted_mod.set_has_mod(false);
				}
			}
		}
	}
	public void get_attack_surround_enemy(ClassCharacterPlayer player, ClassCharacterEnemy enemy, ArrayList<Point> shroud){
		//This check is really just done so that the expensive checks dont always get parsed
		if(!removal_around_enemy.equals("")){
			boolean enemy_uncovered = enemy.uncovered(shroud);
			if(enemy_uncovered && removal_around_enemy.equals("+20%_dbl_dodge")){
				player.dbl_hit_bonus += .2;
				player.dodge_bonus += .2;
			}
			if(enemy_uncovered && removal_around_enemy.equals("first_strike")){
				player.set_contracted_mod("First Strike", true);
			}
		}
	}
	public ArrayList<ClassSpriteLocation> set_see_through_shroud(ClassCharacterPlayer player, ClassPlaceObjects object_reference){
		//This needs to return only icons where the shroud and object are
		String anon_enemy = "icon_haze_enemy.png";
		String anon_spell = "icon_haze_glyph.png";
		String anon_shop = "icon_upgrades.png"; //This will need to be created if it is added to a class
		String anon_item = "haze_powerup.png";
		String anon_altar = "icon_haze_altar.png";
		ArrayList<ClassSpriteLocation> shroud_sprites = new ArrayList<ClassSpriteLocation>();
		for(String see_through_shroud:see_through_shrouds){
			if(!see_through_shroud.equals("")){
				if(see_through_shroud.equals("enemy_lower")){
					for(ClassCharacterEnemy enemy : object_reference.get_enemies()){
						if(object_reference.get_shroud().contains(enemy.get_location()) && player.get_player_variable("level") >= enemy.level){
							shroud_sprites.add(new ClassSpriteLocation(anon_enemy,enemy.get_location()));
						}
					}
				}
				if(see_through_shroud.equals("spell")){
					for(ClassObjectSpellDungeon spell : object_reference.get_spells()){
						if(object_reference.get_shroud().contains(spell.get_location())){
							shroud_sprites.add(new ClassSpriteLocation(anon_spell,spell.get_location()));
						}
					}
				}
				if(see_through_shroud.equals("shop")){
					for(ClassObjectShopDungeon shops : object_reference.get_shops()){
						if(object_reference.get_shroud().contains(shops.get_location())){
							shroud_sprites.add(new ClassSpriteLocation(anon_shop,shops.get_location()));
						}
					}	
				}
				if(see_through_shroud.equals("item")){
					for(ClassObjectPickupDungeon pickup : object_reference.get_pickups()){
						if(object_reference.get_shroud().contains(pickup.get_location())){
							shroud_sprites.add(new ClassSpriteLocation(anon_item,pickup.get_location()));
						}
					}
				}
				if(see_through_shroud.equals("altar")){
					for(ClassObjectGodDungeon altar : object_reference.get_gods()){
						if(object_reference.get_shroud().contains(altar.get_location())){
							shroud_sprites.add(new ClassSpriteLocation(anon_altar,altar.get_location()));
						}
					}
				}
			}
		}
		return shroud_sprites;
	}
	public void set_enemy_visibility(ClassCharacterPlayer player, ArrayList<Point> shroud, ArrayList<ClassCharacterEnemy> enemies){
		if(!enemy_visibility.equals("")){
			int enemy_count = 0;
			for(ClassCharacterEnemy enemy: enemies){
				if(!shroud.contains(enemy.get_location())){
					enemy_count++;
				}
			}
			if(!enemy_visibility.equals("+8%_atk")){
				player.attack_bonus += .08 * enemy_count;
			}
			if(!enemy_visibility.equals("+5_health")){
				player.health_bonus += 5 * enemy_count;
			}
		}
		
	}

}
